<!-- BEGIN PAGE HEADER-->
<?php

$this->load->view('partials/breadcrumb.tpl') ?>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<script language="javascript">
    function defConfirm(url) {
        if (!confirm("确定要删除吗？")) {
            return false;
        }
        window.location.href = url;
        return true;
    }

    $(document).ready(function () {
        $("#reset").click(function () {
            $("select").val('');
            $("input[type='text']").val('');
        });

    });

    function op_check() {
        var selObj = $("#user_op")[0];
        if (selObj.selectedIndex < 1) {
            alert("请选择操作！");
            return false;
        }
        var allUnChecked = true;
        var checkBoxList = $("input[name^='id_time']");
        for (var i = 0; i < checkBoxList.length; i++) {
            if (checkBoxList[i].checked) {
                allUnChecked = false;
                break;
            }
        }
        if (allUnChecked) {
            alert("请选择要操作的用户！");
            return false;
        }
        if (!confirm("确定要 " + $("#user_op").find("option:selected").html() + " 选中的用户么？")) {
            return false;
        }
        $("#user_mng_frm").submit();
    }

    $(document).ready(function () {
        $("#checkall").on('click', function () {
            var ck = $(this).is(":checked");
            var checkBoxList = $("input[name^='id_time']");
            for (var i = 0; i < checkBoxList.length; i++) {
                checkBoxList[i].checked = ck;
                $(checkBoxList[i]).uniform();
            }
        });
    });
</script>
<div class="row">
    <div class="col-xs-12">
        <!-- Begin: life time stats -->
        <div class="portlet light">
            <div class="portlet-title portlet-title-noborder">
                <?= form_open('', Array('class' => 'form-inline', 'role' => 'form')) ?>
                <?= search_form_input('name', filterValue('name'), '用户名'); ?>
                <?= search_form_dropdown('type', array('' => '组类型') + MAdminGroup::$GROUPTYPE, filterValue('type'), '管理员组类型', 'class="form-control input-small" '); ?>
                <?= search_form_dropdown('status', array('' => '状态') + $this->MAdminGroup->getState(), filterValue('status'), '用户状态', 'class="form-control input-small" '); ?>
                <button type="button" class="btn default" id="reset">重置条件</button>
                <button type="submit" class="btn green about_search">搜索 <i class="fa fa-search"></i></button>
                <?= form_close() ?>
            </div>
            <div class="portlet-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-scrollable">
                            <table class="table table-hover table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th width="5%">ID</th>
                                    <th width="10%">组名称</th>
                                    <th width="10%">组类型</th>
                                    <th width="5%">状态</th>
                                    <th width="20%">备注</th>
                                    <th width="20%">创建时间</th>
                                    <th width="20%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                foreach ($adminGroup as $group) {
                                    ?>
                                    <tr>
                                        <td><?= $group->id ?></td>
                                        <td><?= htmlspecialchars($group->name) ?></td>
                                        <td><?= MAdminGroup::$GROUPTYPE[$group->type] ?></td>
                                        <td><?= ($group->status == 0 ? '<span class="label label-warning">禁用</span>' : '<span class="label label-success">启用</span>') ?></td>
                                        <td><?= htmlspecialchars($group->remark) ?></td>
                                        <td><?php echo date('Y-m-d H:i:s', $group->create_time) ?></td>
                                        <td>
                                            <div class="btn-group btn-group-solid">
                                                <?php if ($p->edit) { ?>
                                                <a href="<?= site_url($thisModule . $thisController . '/edit/' . $group->id) ?>"
                                                   class="btn btn-sm purple">
                                                        <i class="fa fa-edit"></i> 编辑</a><?php } else {
                                                    echo '&nbsp;';
                                                } ?>
                                                <?php if ($p->delete) { ?>
                                                    <a href="javascript:void(defConfirm('<?= site_url($thisModule . $thisController . '/delete/' . $group->id . '/' . $group->update_time) ?>'));"
                                                       class="btn btn-sm red">
                                                        <i class="fa fa-times"></i> 删除</a>
                                                <?php } else {
                                                    echo '&nbsp;';
                                                } ?>
                                            </div>
                                        </td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 text-right">
                        <?= $pagination ?>
                    </div>
                </div>
            </div>
        </div>
        <!-- End: life time stats -->
    </div>
</div>
<!-- END PAGE CONTENT-->
